package test.org.example.java.io;

import org.junit.Test;

import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;

/**
 * Created by Juntao.Zhang on 2014/10/22.
 */
public class FileReaderWriter {
  @Test
  public void write() throws Exception {
    FileWriter writer = new FileWriter(new File("data/file_writer.txt"));
    writer.append("hello 张峻滔\n");
    writer.append("hello world");
    writer.close();
  }

  @Test
  public void read() throws Exception {
    FileReader reader = new FileReader(new File("data/file_writer.txt"));
    char[] buffer = new char[32];
    reader.read(buffer);
    System.out.println(new String(buffer));
  }
}
